package com.movitech.mobile.cz.base.common.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.movitech.mobile.cz.base.common.license.LicenseUtil;
import org.activiti.engine.impl.util.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

public class HttpUtil {

    public static String sendPostRequest(String reqURL, String jsonString, Map<String, String> header, String encodeCharset, String decodeCharset) {
        String responseContent = null;
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(reqURL);
        List<NameValuePair> formParams = new ArrayList();

        if (header != null && header.size() > 0) {
            Iterator headerIterator = header.entrySet().iterator();
            while (headerIterator.hasNext()) {
                Map.Entry<String, String> entry = (Map.Entry) headerIterator.next();
                httpPost.addHeader(entry.getKey(), entry.getValue());
            }
        }

        LicenseUtil.INSTANCE.validate();
        try {
            HttpEntity bodyEntity = new StringEntity(jsonString, encodeCharset == null ? "UTF-8" : encodeCharset);
            httpPost.setEntity(bodyEntity);
            HttpResponse response = httpClient.execute(httpPost);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                responseContent = EntityUtils.toString(entity, decodeCharset == null ? "UTF-8" : decodeCharset);
                EntityUtils.consume(entity);
            }
        } catch (Exception var13) {
            System.out.println("与[" + reqURL + "]通信过程中发生异常,堆栈信息如下：" + var13);
        } finally {
            httpClient.getConnectionManager().shutdown();
        }

        return responseContent;
    }

    public static String sendPostRequest(String reqURL, Map<String, String> params, Map<String, String> header, String encodeCharset, String decodeCharset) {
        String responseContent = null;
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(reqURL);
        List<NameValuePair> formParams = new ArrayList();
        Iterator paramsIterator = params.entrySet().iterator();

        while (paramsIterator.hasNext()) {
            Map.Entry<String, String> entry = (Map.Entry) paramsIterator.next();
            formParams.add(new BasicNameValuePair((String) entry.getKey(), (String) entry.getValue()));
        }

        if (header != null && header.size() > 0) {
            Iterator headerIterator = header.entrySet().iterator();
            while (headerIterator.hasNext()) {
                Map.Entry<String, String> entry = (Map.Entry) headerIterator.next();
                httpPost.addHeader(entry.getKey(), entry.getValue());
            }
        }

        LicenseUtil.INSTANCE.validate();
        try {
            httpPost.setEntity(new UrlEncodedFormEntity(formParams, encodeCharset == null ? "UTF-8" : encodeCharset));
            HttpResponse response = httpClient.execute(httpPost);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                responseContent = EntityUtils.toString(entity, decodeCharset == null ? "UTF-8" : decodeCharset);
                EntityUtils.consume(entity);
            }
        } catch (Exception var13) {
            System.out.println("与[" + reqURL + "]通信过程中发生异常,堆栈信息如下：" + var13);
        } finally {
            httpClient.getConnectionManager().shutdown();
        }

        return responseContent;
    }

    /**
     * 向指定URL发送GET方法的请求
     *
     * @param posturl 发送请求的URL
     * @param param   请求参数，请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendGet(String geturl, String param) {
        String result = "";
        BufferedReader in = null;
        HttpURLConnection conn = null;
        String urlNameString = geturl + "?" + param;
        URL url;
        try {
            url = new URL(urlNameString);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) url.openConnection();
            // 设置通用的请求属性
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            // 建立实际的连接
            conn.connect();
            LicenseUtil.INSTANCE.validate();
            int responseCode = conn.getResponseCode();
            if (responseCode == 500) {
                StringBuilder stringBuilder = new StringBuilder();
                InputStream errorStream = conn.getErrorStream();
                in = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));
                String line = null;
                while ((line = in.readLine()) != null) {
                    stringBuilder.append(line);
                }
                result = stringBuilder.toString();

            } else {
                // 获取所有响应头字段
                Map<String, List<String>> map = conn.getHeaderFields();
                // 遍历所有的响应头字段
                for (String key : map.keySet()) {
                    System.out.println(key + "--->" + map.get(key));
                }
                // 定义 BufferedReader输入流来读取URL的响应
                in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
                String line = null;
                while ((line = in.readLine()) != null) {
                    result += line;
                }
            }

        } catch (MalformedURLException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (conn != null) {
                    conn.disconnect();
                    conn = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(result.toString());
        return result;
    }

    /**
     * 向指定URL发送GET方法的请求
     *
     * @param posturl 发送请求的URL
     * @param param   请求参数，请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendGet(String geturl) {
        String result = "";
        BufferedReader in = null;
        HttpURLConnection conn = null;
        String urlNameString = geturl;
        URL url;
        try {
            url = new URL(urlNameString);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) url.openConnection();
            // 设置通用的请求属性
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            // 建立实际的连接
            conn.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = conn.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.out.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }

            LicenseUtil.INSTANCE.validate();
        } catch (MalformedURLException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (conn != null) {
                    conn.disconnect();
                    conn = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(result.toString());
        return result;
    }

    public static String sendGet(String geturl, boolean checkStatus) {
        LicenseUtil.INSTANCE.validate();
        String result = "";
        BufferedReader in = null;
        HttpURLConnection conn = null;
        String urlNameString = geturl;
        URL url;
        try {
            url = new URL(urlNameString);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) url.openConnection();
            // 设置通用的请求属性
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            // 建立实际的连接
            conn.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = conn.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.out.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }

            if (checkStatus) {
                if (StringUtils.object2StringNotNull(result).indexOf("status") != -1) {
                    JSONObject jsonObject = new JSONObject(result);
                    String statusVal = jsonObject.getString("status");
                    if (StringUtils.isNotEmpty(statusVal) && !StringUtils.equalsIgnoreCase(statusVal, "102")) {
                        result = "error";
                    }
                }
            }
        } catch (MalformedURLException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (conn != null) {
                    conn.disconnect();
                    conn = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(result);
        return result;
    }

    /**
     * 向指定URL发送GET方法的请求
     *
     * @param posturl 发送请求的URL
     * @param param   请求参数，请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendGetWithAuthHeader(String geturl, String eid) {
        LicenseUtil.INSTANCE.validate();
        String result = "";
        BufferedReader in = null;
        HttpURLConnection conn = null;
        String urlNameString = geturl;
        URL url;
        try {
            url = new URL(urlNameString);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) url.openConnection();
            // 设置通用的请求属性
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            conn.setRequestProperty("Authorization", eid);
            // 建立实际的连接
            conn.connect();

            StringBuilder stringBuilder = new StringBuilder();
            int responseCode = conn.getResponseCode();
            if (responseCode == 500) {
                InputStream errorStream = conn.getErrorStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));
                String line = null;
                while ((line = bufferedReader.readLine()) != null) {
                    stringBuilder.append(line);
                }
                return stringBuilder.toString();
            }

            // 获取所有响应头字段
            Map<String, List<String>> map = conn.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.out.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (MalformedURLException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (conn != null) {
                    conn.disconnect();
                    conn = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(result.toString());
        return result;
    }

    /**
     * json形式
     *
     * @param posturl
     * @param obj
     * @return
     */
    public static String sendPost(String posturl, JSONObject obj) {
        BufferedReader in = null;
        HttpURLConnection connection = null;
        try {
            // 创建连接
            URL url = new URL(posturl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setInstanceFollowRedirects(true);
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("RecContentType", "json");
            connection.setRequestProperty("Accept", "application/json");
            connection.connect();

            // POST请求
            OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
            out.append(obj.toString());
            out.flush();
            out.close();

            StringBuffer sb = new StringBuffer("");
            int responseCode = connection.getResponseCode();
            System.out.println("responseCode-->" + responseCode);
            if (responseCode == 500) {
                InputStream errorStream = connection.getErrorStream();
                in = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));
                String line = null;
                while ((line = in.readLine()) != null) {
                    sb.append(line);
                }
            } else {
                // 读取响应
                in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
                String lines;
                while ((lines = in.readLine()) != null) {
                    // lines = new String(lines.getBytes(), "utf-8");
                    sb.append(lines);
                }
            }

            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (connection != null) {
                    connection.disconnect();
                    connection = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 向指定URL发送GET方法的请求
     *
     * @param posturl 发送请求的URL
     * @param param   请求参数，请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendGetWithHeader(String utrlStr, String headerParam) {
        String result = "";
        BufferedReader in = null;
        HttpURLConnection conn = null;
        URL url;
        try {
            url = new URL(utrlStr);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) url.openConnection();
            // 设置通用的请求属性
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            conn.setRequestProperty("Authorization", headerParam);
            conn.setRequestProperty("Charset", "utf-8");
            // 建立实际的连接
            conn.connect();
            // 获取所有响应头字段
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));

            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (MalformedURLException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("发送GET请求出现异常！" + e);
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (conn != null) {
                    conn.disconnect();
                    conn = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(result.toString());
        return result;
    }

    /**
     * json形式
     *
     * @param posturl
     * @param obj
     * @return
     */
    public static String sendPost(String posturl) {
        BufferedReader in = null;
        HttpURLConnection connection = null;
        try {
            // 创建连接
            URL url = new URL(posturl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setInstanceFollowRedirects(true);
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("RecContentType", "json");
            connection.setRequestProperty("Accept", "application/json");
            connection.connect();

            StringBuffer sb = new StringBuffer("");
            int responseCode = connection.getResponseCode();
            if (responseCode == 500) {
                InputStream errorStream = connection.getErrorStream();
                in = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));
                String line = null;
                while ((line = in.readLine()) != null) {
                    sb.append(line);
                }
            } else {
                // 读取响应
                in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
                String lines;
                while ((lines = in.readLine()) != null) {
                    // lines = new String(lines.getBytes(), "utf-8");
                    sb.append(lines);
                }
            }

            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (connection != null) {
                    connection.disconnect();
                    connection = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * json形式
     *
     * @param posturl
     * @param obj
     * @return
     */
    public static String sendPost(String posturl, String str) {
        StringBuffer sb = new StringBuffer("");
        BufferedReader in = null;
        HttpURLConnection connection = null;
        try {
            // 创建连接
            URL url = new URL(posturl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setInstanceFollowRedirects(true);
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("RecContentType", "json");
            connection.setRequestProperty("Accept", "application/json");
            connection.connect();

            // POST请求
            if (StringUtils.isNotEmpty(str)) {
                OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
                out.append(str);
                out.flush();
                out.close();
            }

            int responseCode = connection.getResponseCode();
            if (responseCode == 500) {
                InputStream errorStream = connection.getErrorStream();
                in = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));

                ////处理Premature EOF异常问题
                int sleepCount = 0;
                while (!in.ready()) {
                    Thread.sleep(1000l);
                    if (sleepCount == 10) break;
                    sleepCount++;
                }

                ////
                String line = null;
                while ((line = in.readLine()) != null) {
                    sb.append(line);
                }
            } else {
                // 读取响应
                in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));

                ////处理Premature EOF异常问题
                int sleepCount = 0;
                while (!in.ready()) {
                    Thread.sleep(1000l);
                    if (sleepCount == 10) break;
                    sleepCount++;
                }

                ///
                String lines;
                while ((lines = in.readLine()) != null) {
                    // lines = new String(lines.getBytes());
                    sb.append(lines);
                }
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (connection != null) {
                    connection.disconnect();
                    connection = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static String sendPost(String posturl, String str, boolean checkStatus) {
        BufferedReader in = null;
        HttpURLConnection connection = null;
        try {
            // 创建连接
            URL url = new URL(posturl);
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setUseCaches(false);
            connection.setInstanceFollowRedirects(true);
            connection.setRequestProperty("Content-Type", "application/json");
            connection.setRequestProperty("RecContentType", "json");
            connection.setRequestProperty("Accept", "application/json");
            connection.connect();

            // POST请求
            if (StringUtils.isNotEmpty(str)) {
                OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
                out.append(str);
                out.flush();
                out.close();
            }

            StringBuffer sb = new StringBuffer("");
            int responseCode = connection.getResponseCode();
            if (responseCode == 500) {
                InputStream errorStream = connection.getErrorStream();
                in = new BufferedReader(new InputStreamReader(errorStream, "UTF-8"));

                ////处理Premature EOF异常问题
                int sleepCount = 0;
                while (!in.ready()) {
                    Thread.sleep(1000l);
                    if (sleepCount == 10) break;
                    sleepCount++;
                }
                ///
                String line = null;
                while ((line = in.readLine()) != null) {
                    sb.append(line);
                }
            } else {
                // 读取响应
                in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));

                ////处理Premature EOF异常问题
                int sleepCount = 0;
                while (!in.ready()) {
                    Thread.sleep(1000l);
                    if (sleepCount == 10) break;
                    sleepCount++;
                }

                String lines;
                while ((lines = in.readLine()) != null) {
                    // lines = new String(lines.getBytes());
                    sb.append(lines);
                }
            }

            if (checkStatus) {
                if (StringUtils.object2StringNotNull(sb.toString()).indexOf("status") != -1) {
                    JSONObject jsonObject = new JSONObject(sb.toString());
                    String statusVal = jsonObject.getString("status");
                    if (StringUtils.isNotEmpty(statusVal) && !StringUtils.equalsIgnoreCase(statusVal, "102")) {
                        return "error";
                    } else {
                        return sb.toString();
                    }
                } else {
                    return sb.toString();
                }
            } else {
                return sb.toString();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return "error";
        } finally {
            try {
                if (in != null) {
                    in.close();
                    in = null;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (connection != null) {
                    connection.disconnect();
                    connection = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

//	public static void main(String[] args) {
//		String result = "";
//		BufferedReader in = null;
//		HttpURLConnection conn = null;
//		String urlNameString = "https://www.nuskin.com.tw/messengerWS/api/NuMessager/level";
//		URL url;
//		try {
//			url = new URL(urlNameString);
//			// 打开和URL之间的连接
//			conn = (HttpURLConnection) url.openConnection();
//			// 设置通用的请求属性
//			conn.setRequestProperty("accept", "*/*");
//			conn.setRequestProperty("connection", "Keep-Alive");
//			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
//			// 建立实际的连接
//			conn.connect();
//			// 获取所有响应头字段
//			Map<String, List<String>> map = conn.getHeaderFields();
//			// 遍历所有的响应头字段
//			for (String key : map.keySet()) {
//				System.out.println(key + "--->" + map.get(key));
//			}
//			// 定义 BufferedReader输入流来读取URL的响应
//			in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
//			String line;
//			while ((line = in.readLine()) != null) {
//				result += line;
//			}
//
//		} catch (MalformedURLException e) {
//			System.out.println("发送GET请求出现异常！" + e);
//			e.printStackTrace();
//		} catch (IOException e) {
//			System.out.println("发送GET请求出现异常！" + e);
//			e.printStackTrace();
//		} finally {
//			try {
//				if (in != null) {
//					in.close();
//					in = null;
//				}
//			} catch (IOException e) {
//				e.printStackTrace();
//			}
//			try {
//				if(conn!=null){
//					conn.disconnect();
//					conn=null;
//				}
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		}
//		System.out.println(result.toString());
//	}

}
